<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 父组件模板-->
    <div id="app">
        <cpn ref="a"></cpn>
        <cpn ref="b"></cpn>
        <cpn ref="c"></cpn>
        <button @click="btnClick">+</button>
    </div>  
 <template id="cpn">
    <div>
        <h2>我是子组件</h2>
    </div>
 </template>
    <script src="../js/vue.js"></script>
    <script>
          //父组件 ------ 双向绑定案例
          const app=new Vue({
            el:'#app',
            methods:{
                    btnClick(){
                            // console.log(this.$children)
                            // for (let c of this.$children){
                            //     c.showMessage()
                            // }
                            console.log("---")
                            console.log(this.$refs.a.name)
                    }
                },
            data:{
                message: "aa",
            },
            components:{
                    //组件名称
                    cpn:{
                        template:"#cpn",
                        data(){
                            return {
                                name:"我是子组件的name"
                            }
                        },
                        methods:{
                            showMessage(){
                                console.log("showMessage")
                            }
                        }
                    }
                }
        })
    </script>
</body>
</html>